﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TSharp.Core.Authorization.Control
{
    /// <summary>
    /// 权限管理数据访问接口，用于解耦具体实现的数据访问
    /// </summary>
    public interface IControlManagerDao
    {
        /// <summary>
        /// 获取指定参与者对指定资源或者资源组的操作权限
        /// </summary>
        int? GetControlData(string resourceCategoryCode, Guid actorId, Guid resourceId);
         
        /// <summary>
        /// 获取指定参与者相关的所有资源的操作权限列表
        /// </summary>
        List<ResourcePermissionKeyValue> GetControlDatasByActor(string resourceCategoryCode, Guid actorId);

        /// <summary>
        /// 获取所有参与者对指定资源的操作权限列表，对初始化的资源类别有效
        /// </summary>
        List<ResourcePermissionKeyValue> GetControlDatasByResource(string resourceCategoryCode, Guid resourceId);

        /// <summary>
        /// 获取多个参与者对多个资源或者多个资源组的操作权限列表
        /// </summary>
        void GetControlDatas(string resourceCategoryCode, List<Guid> actorsId, List<Guid> resourcesId, List<int> operationsCode);

        /// <summary>
        /// 获取多个参与者拥有指定操作权限的资源或者资源组代码列表
        /// </summary>
        List<Guid> GetAllowActResources(string resourceCategoryCode, List<Guid> actorsId, int operationCode);

        /// <summary>
        /// 获取多个参与者禁止指定操作权限的资源或者资源组代码列表
        /// </summary>
        void GetForbidActResources(string resourceCategoryCode, List<Guid> actorsId, int operationCode, List<Guid> resourcesId);

        /// <summary>
        /// 添加或者更新权限
        /// </summary>
        bool AddOrEditControlData(string resourceCategoryCode, Guid actorId, Guid resourceId, int operationCode);

        /// <summary>
        /// 删除指定参与者对指定资源的权限
        /// </summary>
        bool RemoveControlData(string resourceCategoryCode, Guid actorId, Guid resourceId);

        /// <summary>
        /// 删除指定参与者的所有权限
        /// </summary>
        bool RemoveActorControlDatas(string resourceCategoryCode, Guid actorId);

        /// <summary>
        /// 删除指定资源的所有权限
        /// </summary>
        bool RemoveResourceControlDatas(string resourceCategoryCode, Guid resourceId);
    }
}
